<template>
  <div class="main">
    <header>
      <header-1></header-1>
      <header-2></header-2>

      <div class="nav_list">
        <div><router-link to="/city">{{$route.params.city==undefined?"深圳":$route.params.city}}<span class="down_list">▼</span></router-link></div>
        <div>
          <ul class="nav_list_template">
            <li v-for="(item,index) in nav" :key="item.id" @click="aniamtion_left(index)">
              <router-link :to="item.path">{{ item.val }}</router-link>
            </li>
            <div :style="red_div"></div>
          </ul>
        </div>
        <div>
          <img
            src="https://s0.meituan.net/bs/myfe/canary/file/touchnode/images/dpmmweb/component/index/img/base64/search-red.png"
          />
        </div>
      </div>
    </header>

    <article ref="scroll_main">
      <router-view></router-view>
    </article>
  </div>
</template>

<script>
//引入 axios
import axios from "axios";
import Header1 from "../../components/Header1.vue";
import Header2 from "../../components/Header2.vue";

export default {
  components: { Header1, Header2 },
  name: "movie",
  data() {
    return {
      red_div:"left: 0.48rem;",
      red_divs:["left: 0.48rem;","left: 1.96rem","left: 3.45rem;","left: 5.25rem"],
      nav: [
        { id: 1, path: "hot", val: "热映" },
        { id: 2, path: "cinema", val: "电影" },
        { id: 3, path: "daiying", val: "待映" },
        { id: 4, path: "classicmovie", val: "经典电影" },
      ],
      data: {
        hot: [],
      }, //保持热映电影的数组的数据
    };
  },
  methods: {
    aniamtion_left(index){ //控制红色小标移动动画
        this.red_div = this.red_divs[index];
    }
  },
  created() {
      console.log(this.$route);

      switch(this.$route.name){
          case 'Hot': this.red_div = this.red_divs[0];break;
          case 'Cinema': this.red_div = this.red_divs[1];break;
          case 'DaiYing': this.red_div = this.red_divs[2];break;
          case 'ClassicMovie': this.red_div = this.red_divs[3];break;
      }
    //使用axios 获取数据
    axios
      .get("api/mmdb/movie/v3/list/hot.json?ct=热点&ci=30&channelId=4")
      .then((data) => {
        this.data = data.data.data;
        this.data.hot.forEach((e) => {
          e.img = e.img.replace("w.h", "128.180"); //64*90
        });
        this.data.hot.sort((a, b) => {
          if (a.sc == 0 || a.sc < b.sc) return 1;
          else return -1;
        });

        console.log("movie: ",JSON.parse(JSON.stringify(this.data)));
      })
      .catch((error) => console.log("获取数据失败!", error));
  }
};
</script>

<style >
/* scoped 表示 样式只在当前页有效果 */
body header,
html header,
header {
  min-height: 4rem;
  width: 100%;
}

a {
  text-decoration: none;
  color: #666;
}
.main {
  width: 100%;
  min-height: 4rem;
  flex: 1 1 auto;
  overflow: scroll;
}


body header .nav_list,
html header .nav_list,
header .nav_list {
  width: 100%;
  height: 30%;
  display: flex;
  background-color: white;
  border-top: 0.5px solid #ebebeb;
  border-bottom: 0.5px solid #ebebeb;
  box-sizing: border-box;
}

body header .nav_list > div:nth-of-type(1),
html header .nav_list > div:nth-of-type(1),
header .nav_list > div:nth-of-type(1) {
  width: 1.4rem;
  display: flex;
  align-items: center;
  font-size: 0.373333rem;
  color: #666;
  padding-left: 10px;
}

body header .nav_list > div:nth-of-type(1) .down_list,
html header .nav_list > div:nth-of-type(1) .down_list,
header .nav_list > div:nth-of-type(1) .down_list {
  font-size: 0.32rem;
  transform: scaleY(0.7);
}

body header .nav_list > div:nth-of-type(2),
html header .nav_list > div:nth-of-type(2),
header .nav_list > div:nth-of-type(2) {
  flex: 1 1 auto;
}

body header .nav_list > div:nth-of-type(3),
html header .nav_list > div:nth-of-type(3),
header .nav_list > div:nth-of-type(3) {
  width: 1.4rem;
  display: flex;
  justify-content: right;
  align-items: center;
  padding-right: 10px;
}

body header .nav_list > div:nth-of-type(3) img,
html header .nav_list > div:nth-of-type(3) img,
header .nav_list > div:nth-of-type(3) img {
  width: 0.6rem;
}

.nav_list_template {
  list-style: none;
  width: 100%;
  height: 100%;
  display: flex;
  position: relative;
}

.nav_list_template a.router-link-exact-active {
  color: black;
  transform: scale(1.15);
}


.nav_list_template li {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  font-size: 0.373333rem;
  font-weight: bold;
  color: #666;
}

.nav_list_template > div {
  position: absolute;
  bottom: 0;
  height: 2px;
  margin-bottom: 3px;
  width: 20px;
  transition: 0.3s;
  z-index: 2;
  background-color: #e54847;
 
}

body article,
html article,
article {
  flex: 1 1 auto;
  overflow-y: scroll;
}

body article .have_the_call,
html article .have_the_call,
article .have_the_call {
  width: 100%;
  background-color: white;
  margin-bottom: 0.266667rem;
}

body article .have_the_call > div,
html article .have_the_call > div,
article .have_the_call > div {
  padding-right: 10px;
  padding-left: 10px;
}

body article .have_the_call > div > div:nth-of-type(1),
html article .have_the_call > div > div:nth-of-type(1),
article .have_the_call > div > div:nth-of-type(1) {
  width: 100%;
  height: 1.333333rem;
  line-height: 1.333333rem;
  font-size: 14px;
}

body article .have_the_call > div > div:nth-of-type(2),
html article .have_the_call > div > div:nth-of-type(2),
article .have_the_call > div > div:nth-of-type(2) {
  height: 4rem;
  overflow-x: scroll;
}

body article .have_the_call > div > div:nth-of-type(2) ul,
html article .have_the_call > div > div:nth-of-type(2) ul,
article .have_the_call > div > div:nth-of-type(2) ul {
  list-style: none;
  display: flex;
}

body article .have_the_call > div > div:nth-of-type(2) ul li,
html article .have_the_call > div > div:nth-of-type(2) ul li,
article .have_the_call > div > div:nth-of-type(2) ul li {
  width: 2.16rem;
  margin-right: 0.32rem;
}

body article .have_the_call > div > div:nth-of-type(2) ul li > div,
html article .have_the_call > div > div:nth-of-type(2) ul li > div,
article .have_the_call > div > div:nth-of-type(2) ul li > div {
  width: 2.3rem;
  height: 3.066667rem;
  position: relative;
}

body article .have_the_call > div > div:nth-of-type(2) ul li > div img,
html article .have_the_call > div > div:nth-of-type(2) ul li > div img,
article .have_the_call > div > div:nth-of-type(2) ul li > div img {
  width: 100%;
  height: 3.066667rem;
  position: absolute;
}

body article .have_the_call > div > div:nth-of-type(2) ul li > div > div,
html article .have_the_call > div > div:nth-of-type(2) ul li > div > div,
article .have_the_call > div > div:nth-of-type(2) ul li > div > div {
  position: absolute;
  width: 100%;
  height: 3.066667rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-shadow: 0px -0.8rem 0.533333rem -0.266667rem #000 inset;
  font-size: 0.32rem;
  z-index: 3;
  font-weight: bold;
  color: #faaf00;
}

body article .have_the_call > div > div:nth-of-type(2) ul li p,
html article .have_the_call > div > div:nth-of-type(2) ul li p,
article .have_the_call > div > div:nth-of-type(2) ul li p {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  margin-top: 0.133333rem;
  font-size: 13px;
  font-weight: bold;
}

body article .have_the_call > div > div::-webkit-scrollbar,
html article .have_the_call > div > div::-webkit-scrollbar,
article .have_the_call > div > div::-webkit-scrollbar {
  display: none;
}

body article .call_list,
html article .call_list,
article .call_list {
  background-color: white;
}

body article .call_list > div,
html article .call_list > div,
article .call_list > div {
  height: 100%;
  padding-right: 10px;
  padding-left: 10px;
}

body article .call_list > div ul li,
html article .call_list > div ul li,
article .call_list > div ul li {
  width: 100%;
  height: 3.066667rem;
  display: flex;
}

body article .call_list > div ul li > div:nth-of-type(1),
html article .call_list > div ul li > div:nth-of-type(1),
article .call_list > div ul li > div:nth-of-type(1) {
  width: 1.706667rem;
  height: 100%;
  display: flex;
  align-items: center;
}

body article .call_list > div ul li > div:nth-of-type(1) img,
html article .call_list > div ul li > div:nth-of-type(1) img,
article .call_list > div ul li > div:nth-of-type(1) img {
  width: 1.706667rem;
  height: auto;
}

body article .call_list > div ul li > div:nth-of-type(2),
html article .call_list > div ul li > div:nth-of-type(2),
article .call_list > div ul li > div:nth-of-type(2) {
  flex: 1 1 auto;
  display: flex;
  box-sizing: border-box;
  border-bottom: 1px solid #ebebeb;
}

body article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(1),
html article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(1),
article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(1) {
  flex: 1 1 auto;
  padding-left: 0.266667rem;
  display: flex;
  flex-direction: column;
  align-content: center;
  overflow: hidden;
}

body
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(1)
  h1,
html
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(1)
  h1,
article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(1) h1 {
  padding-top: 10px;
  padding-bottom: 10px;
  box-sizing: border-box;
  font-weight: bold;
  font-size: 17px;
}

body article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(1) p,
html article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(1) p,
article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(1) p {
  font-size: 0.346667rem;
  padding-top: 2px;
  display: inline-block;
  width: 5.333333rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(1)
  p
  .golden_font,
html
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(1)
  p
  .golden_font,
article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(1)
  p
  .golden_font {
  font-size: 15px;
  color: #faaf00;
  font-weight: bold;
}

body article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(2),
html article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(2),
article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(2) {
  width: 60px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

body
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(2)
  > button,
html
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(2)
  > button,
article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(2)
  > button {
  width: 50px;
  height: 30px;
  border: 0;
  color: white;
  border-radius: 0.533333rem;
}

body
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(2)
  .red,
html
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(2)
  .red,
article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(2) .red {
  background-color: #e54847;
}

body
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(2)
  .blue,
html
  article
  .call_list
  > div
  ul
  li
  > div:nth-of-type(2)
  > div:nth-of-type(2)
  .blue,
article .call_list > div ul li > div:nth-of-type(2) > div:nth-of-type(2) .blue {
  background-color: #3c9fe6;
}

.main {
  display: flex;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  flex-direction: column;
}

article {
  flex: 1 1 auto !important;
  width: 100%;
  overflow: scroll;
}

a.router-link-active ,a.router-link-active *{
    color: red;
    fill: red;
}
</style>